package org.jeecg.modules.hotel.exchangebed.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rabbitmq.client.AMQP;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.hotel.check.entity.Repeat;
import org.jeecg.modules.hotel.check.service.IcheckService;
import org.jeecg.modules.hotel.exchangebed.entity.Exchange;
import org.jeecg.modules.hotel.exchangebed.service.IExchangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Title: ExchangeBedController
 * @Description: 床位交换
 * @Author sn
 * @Date 2022-07-27
 * @Version V1.0
 */
@Slf4j
@RestController
@RequestMapping("/sys/exchange")
@Api(tags="床位交换")
public class ExchangeBedController {


	@Autowired
	private IExchangeService exchangeService;

	/**
	 * 分页列表查询
	 *
	 * @param exchange
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	@AutoLog(value = "床位交换列表查询")
	@ApiOperation(value="床位交换列表查询", notes="床位交换列表查询")
	@GetMapping(value = "/list")
	public Result<?> end(Exchange exchange,
						 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
						 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
						 HttpServletRequest req) {

		IPage<Exchange> queryList  = exchangeService.findList(exchange);
		return Result.OK(queryList);
	}



	/**
	 * 查询所有楼-单元-层-房间
	 */
	@AutoLog(value = "房间信息-通过pid查询")
	@ApiOperation(value = "房间信息-通过pid查询", notes = "房间信息-通过pid查询")
	@GetMapping(value = "/getRoomData")
	public Result<?> getRoomData(@RequestParam(name = "pid") String pid) {
		System.out.println("pid ------>>>> " + pid);
		List<Map<String, String>> maps = exchangeService.listByPid2(pid);
		maps.forEach(System.out::println);
		return Result.OK(maps);
	}

	/**
	 * 查询所有楼-单元-层-房间
	 */
	@AutoLog(value = "交换床位")
	@ApiOperation(value = "交换床位", notes = "交换床位")
	@GetMapping(value = "/exchangeBed")
	public Result<?> exchangeBed(Exchange exchange) {
		return exchangeService.exchangeBed(exchange);

	}
}
